package com.igoal.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Repository;

import com.igoal.entity.FamousQuote;

@Repository("famousQuoteDAO")
public class FamousQuoteDAOImpl extends GenericDaoHibernate<FamousQuote, Long>
		implements FamousQuoteDAO {

	public FamousQuoteDAOImpl() {
		super(FamousQuote.class);
	}

	public FamousQuote genrateRandomQuote() {
		DetachedCriteria dc = DetachedCriteria.forClass(FamousQuote.class);
		getRandomEntities(dc);
		List<FamousQuote> list = findByCriteria(dc, 0, 1);
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}
}